// pages/subject/subject.js
const app = getApp();
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */ 
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      imgPath: app.d.imgPath
    })
    this.getSystemInfo();
    this.getProCate();
  },

  getSystemInfo: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          height: res.windowHeight,
          width: res.windowHeight
        })
      }
    })
  },

  /*获取产品分类列表*/
  getProCate: function (param) {
    var that = this;
    var sucFunc = function (that, res) {
      console.log(res.data)
      if(res.data.package_id > 1){
        wx.navigateTo({
          url: "/pages/test/project?id=" + res.data.subject,
        })
      }
      that.setData({
        nav:res.data
      })
    }
    var data = {openid:app.d.openid}
    utils.wxRequest(that, app.d.path, "Profession/index", data, sucFunc);
  },

  /*nav点击改变当前的产品分类*/
  changeCurCate: function (e) {
    console.log(e);
    var that = this;
    var curCate = e.currentTarget.dataset.id;
    // if (curCate != that.data.curCate) {
    //   that.setData({
    //     curCate: curCate
    //   })
      wx.navigateTo({
        url: "/pages/test/project?id="+curCate,
      })
    // }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})